package com.hmdp.mapper;

import com.hmdp.entity.Follow;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
public interface FollowMapper extends BaseMapper<Follow> {

    @Delete("delete from tb_follow where user_id = #{userId} and follow_user_id = #{followUserId}")
    Boolean deleteByFollowUserIdAndUserId(@Param("followUserId") Long followUserId, @Param("userId") Long userId);


    Boolean insertRecord(@Param("follow") Follow follow);

    @Select("select count(*) from tb_follow where user_id = #{userId} and follow_user_id = #{followUserId}")
    Integer countByFollowUserIdAndUserId(@Param("followUserId") Long followUserId, @Param("userId") Long userId);


    @Select("select * from tb_follow where follow_user_id = #{followUserId}")
    List<Follow> queryAllByFollowUserId(@Param("followUserId") Long followUserId);

}
